#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> arr[i];
    }
    int res = 0, left = 0, right = 1;
    while(right < n)
    {
        while(right < n && arr[right] - arr[right - 1] <= 8)
        {
            ++right; // 不用加绝对值是低音可以唱
        }
        res = max(res, right - left); // right已经多++了，不用再+1
        left = right;
        ++right;
    }
    cout << res;
    return 0;
}